Learn how to track Search Analytics in Algolia extension for Magento 2.
analytics
widget calls the push
function every time it has to send analytics data to an analytics service.
If Google Analytics is enabled in Magento, the widget will automatically configure the push
function to send the data to Google Analytics. You can configure Magento’s Google Analytics settings by going to: Stores > Configuration > Sales > Google API > Google Analytics
Each search will be tracked as a page view in Google Analytics.
The URL of the page view will have the following format:
/catalogsearch/result/?q=[[search_term]]&[[selected_filters]]&numberOfHits=[[number_of_results]]
push
function on GitHub if interested.push
function needs to be written.
This can be done by defining a algoliaAnalyticsPushFunction
variable, and assigning the custom function to it.
The widget automatically calls the custom function, so there’s no need to do anything else.
The custom function will be passed three variables: formattedParameters
, state
, and results
.